package com.star.mentor.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.star.core.base.BaseController;
import com.star.mentor.dto.EvaluationDTO;
import com.star.mentor.dto.MentorEvaluationPageWxmentorDTO;
import com.star.mentor.service.MentorEvaluationService;
import com.star.mentor.vo.MentorEvaluationPageWxmentorVO;
import com.star.security.annotations.Authorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 导师评估艺人
 *
 * @author yangzj
 */
@RestController
@RequestMapping("/mentor-evaluation")
public class MentorEvaluationController extends BaseController {

    @Autowired
    private MentorEvaluationService mentorEvaluationService;

    /**
     * 分页-微信小程序（导师端）
     *
     * @param dto 入参
     * @return {@link IPage}<{@link MentorEvaluationPageWxmentorVO}>
     */
    @Authorize("wxmentor")
    @PostMapping("/wxmentor/page")
    public IPage<MentorEvaluationPageWxmentorVO> pageWxmentor(@Validated @RequestBody MentorEvaluationPageWxmentorDTO dto) {
        return mentorEvaluationService.pageWxmentor(dto.setUserId(getUserId()));
    }

    /**
     * 导师评估-微信小程序（导师端）
     *
     * @param dto 入参
     */
    @Authorize("wxmentor")
    @PostMapping("/wxmentor/evaluation")
    public void evaluation(@Validated @RequestBody EvaluationDTO dto) {
        mentorEvaluationService.evaluation(dto, getUserId());
    }

    /**
     * 更新是否关注-微信小程序（导师端）
     *
     * @param starId    艺人ID
     * @param isCollect 是否关注
     */
    @Authorize("wxmentor")
    @PutMapping("/wxmentor/collect/{starId}/{isCollect}")
    public void updateCollect(@PathVariable("starId") Long starId, @PathVariable("isCollect") Boolean isCollect) {
        mentorEvaluationService.updateCollect(starId, isCollect, getUserId());
    }

}
